package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Tourist;
import cn.wolfcode.luowowo.article.mapper.TouristMapper;
import cn.wolfcode.luowowo.article.service.ITouristService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class TouristServiceImpl implements ITouristService {

    @Autowired
    private TouristMapper touristMapper;

    @Override
    public void saveOrUpdate(Tourist tourist) {
        if (tourist.getId() != null) {
            touristMapper.updateByPrimaryKey(tourist);
        }else {
            touristMapper.insert(tourist);
        }
    }

    @Override
    public Tourist get(Long id) {
        return touristMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Tourist> listAll() {
        return touristMapper.selectAll();
    }

    @Override
    public List<Tourist> queryTop5ByDestId(Long destId) {

        return touristMapper.selectByDestId(destId);
    }
}
